package com.anycc.cloud.core.repository;

import com.anycc.cloud.core.entity.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

/**
 * role repository
 */
public interface RoleRepository extends JpaRepository<Role, String>, JpaSpecificationExecutor<Role> {
    /**
     * find role by name or sn
     *
     * @param name name
     * @param sn   sn
     * @return Role
     */
    List<Role> findByNameOrSn(String name, String sn);

    /**
     * find role by permission"s module id
     *
     * @param moduleId moduleI d
     * @return List<Role>
     */
    List<Role> findByPermissionsModuleId(String moduleId);

    /**
     * find role which id in permissionIds
     *
     * @param permissionIds permission id collection
     * @return List
     */
    List<Role> findByPermissionsIdIn(List<String> permissionIds);

    /**
     * find role by sn
     *
     * @param sn sn
     * @return Role
     */
    Role findBySn(String sn);
}
